/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PersonEditorDialog.java
 *
 * Created on Apr 20, 2011, 4:42:35 PM
 */

package vita;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import org.jdesktop.application.Action;

/**
 *
 * @author chrisf
 */
public class PersonEditorDialog extends javax.swing.JDialog {

    private String iconDirectory = System.getProperty("user.dir")+System.getProperty("file.separator")+"Icons";
    private Person p;
    final JFileChooser fc = new JFileChooser();


    /** Creates new form PersonEditorDialog */
    public PersonEditorDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        p=null;
    }


    public Person openPersonForEdit(Person person) {
        p=person;
        populateFormWithPerson();
        this.setVisible(true);
        return p;
    }

    private void populateFormWithPerson() {
        birthLocationField.setText(p.getBirthLocation());
        birthYearField.setText(getStringValue(p.getBirthYear()));
        commemorationDayCombo.setSelectedItem(p.getCommemorationDay());
        commemorationMonthCombo.setSelectedItem(p.getCommemorationMonth());
        deathLocationField.setText(p.getDeathLocation());
        deathYearField.setText(getStringValue(p.getDeathYear()));

        iconsComboBox.removeAllItems();
        for(int i =0; i<p.getIcons().size(); i++) {
            String el = (String)p.getIcons().get(i);
            if (!el.equals("NULL")) {
                System.out.println("PersonEditorFrame::populateFormWithPerson: adding to iconListBox: " + el);
                iconsComboBox.addItem(el);
            }
        }

    //importIconTextField.setText(p.get);
//    jCheckBox1;
//    jList1;
//    jList2;
//    jList3;
        lifeLocationField.setText(p.getLifeLocation());
        lifeStoryField.setText(p.getLifeStory());
        nameField.setText(p.getName());
        relicsLocationField.setText(p.getRelicsLocation());
    }

    private String getStringValue(Integer i) {
        String retVal="";
        if (i != null) retVal=Integer.toString(i);
        return retVal;
    }


    private void updatePerson() {
        p.setBirthLocation(birthLocationField.getText());
        p.setBirthYear(Integer.parseInt(birthYearField.getText()));
        p.setCommemorationDay((String)commemorationDayCombo.getSelectedItem());
        p.setCommemorationMonth((String)commemorationMonthCombo.getSelectedItem());
        p.setDeathLocation(deathLocationField.getText());
        p.setDeathYear(Integer.parseInt(deathYearField.getText()));

        p.getIcons().clear();
        for(int i =0; i<iconsComboBox.getItemCount(); i++) {
            String item = (String)iconsComboBox.getItemAt(i);
            p.getIcons().add(item);
        }

    //importIconTextField.setText(p.get);
//    jCheckBox1;
//    jList1;
//    jList2;
//    jList3;
        p.setLifeLocation(lifeLocationField.getText());
        p.setLifeStory(lifeStoryField.getText());
        p.setName(nameField.getText());
        p.setRelicsLocation(relicsLocationField.getText());

    }

    public void addImage(String filePath) {
        File f = new File(filePath);
        String outPath = iconDirectory + System.getProperty("file.separator") + f.getName();

        // Copy file to icon directory
        if (!f.exists()) copyFile(f.getAbsolutePath(),outPath);

        // add item to person's icon list
        if (!p.getIcons().contains(f.getName())) p.getIcons().add(f.getName());

        // add item to list box in gui
        int selectedIndex=comboBoxContainsItem(iconsComboBox, f.getName());
        if (selectedIndex==-1) {
            iconsComboBox.addItem(f.getName());
            selectedIndex=iconsComboBox.getItemCount()-1;
        }
        if (selectedIndex != iconsComboBox.getSelectedIndex()) {
            iconsComboBox.setSelectedIndex(selectedIndex);
            updateIcon();
        }
    }

    private int comboBoxContainsItem(JComboBox cb, Object item) {
        int matchIndex=-1;
        for(int i=0; i<cb.getItemCount(); i++) {
            String itemString = (String)item;
            String cbItemString = (String)cb.getItemAt(i);
            if(itemString.equals(cbItemString)) {
                matchIndex=i;
                break;
            }
        }
        return matchIndex;
    }

    @Action
    private void updateIcon() {
        int selectedIndex = iconsComboBox.getSelectedIndex();
        if ( selectedIndex>=0 ) {
           String srcFile = iconDirectory + System.getProperty("file.separator") + iconsComboBox.getItemAt(selectedIndex);
           iconsImagePanel.setImage(srcFile);
           iconsImagePanel.repaint();
        }
    }


    public void copyFile (String inPath, String outPath) {
        try {
            FileInputStream in = new FileInputStream(inPath);
            FileOutputStream out = new FileOutputStream(outPath);
            byte[] buf = new byte[1024];
            int i = 0;
            while ((i = in.read(buf)) != -1) {
                out.write(buf, 0, i);
            }
            in.close();
            out.close();
        } catch(IOException e) {
            System.out.println("Error copying file");
            e.printStackTrace();
        }
    }


    @Action
    public void openFileChoser() {
        int returnVal = fc.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            importIconTextField.setText(fc.getSelectedFile().getAbsolutePath());
        }
    }

    @Action
    public void importImageButtonPressed() {
        addImage(importIconTextField.getText());
    }


    @Action
    public void cancelButtonPressed() {
System.out.println("PersonEditorDialog::cancelButtonPressed");
        this.setVisible(false);
    }

    @Action
    public void okayButtonPressed() {
System.out.println("PersonEditorDialog::okayButtonPressed");
        updatePerson();
        this.setVisible(false);
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cancelButtonPersonEditor = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jCheckBox1 = new javax.swing.JCheckBox();
        deathYearField = new javax.swing.JTextField();
        commemorationMonthCombo = new javax.swing.JComboBox();
        nameLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        birthLocationLabel = new javax.swing.JLabel();
        birthLocationField = new javax.swing.JTextField();
        lifeLocationLabel = new javax.swing.JLabel();
        lifeLocationField = new javax.swing.JTextField();
        deathLocationLabel = new javax.swing.JLabel();
        deathLocationField = new javax.swing.JTextField();
        relicsLocationLabel = new javax.swing.JLabel();
        relicsLocationField = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        lifeStoryField = new javax.swing.JTextArea();
        commemorationDayCombo = new javax.swing.JComboBox();
        jPanel4 = new javax.swing.JPanel();
        importIconTextField = new javax.swing.JTextField();
        importIconButton = new javax.swing.JButton();
        navigateButton = new javax.swing.JButton();
        deleteImageButton = new javax.swing.JButton();
        iconsComboBox = new javax.swing.JComboBox();
        iconsImagePanel = new vita.ImagePanel();
        birthYearLabel = new javax.swing.JLabel();
        nameLabel = new javax.swing.JLabel();
        birthYearLabel1 = new javax.swing.JLabel();
        birthYearField = new javax.swing.JTextField();
        birthYearLabel2 = new javax.swing.JLabel();
        nameField = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        okayButtonPersonEditor = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(vita.VitaApp.class).getContext().getActionMap(PersonEditorDialog.class, this);
        cancelButtonPersonEditor.setAction(actionMap.get("cancelButtonPressed")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(vita.VitaApp.class).getContext().getResourceMap(PersonEditorDialog.class);
        cancelButtonPersonEditor.setText(resourceMap.getString("cancelButtonPersonEditor.text")); // NOI18N
        cancelButtonPersonEditor.setName("cancelButtonPersonEditor"); // NOI18N

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel6.border.title"))); // NOI18N
        jPanel6.setName("jPanel6"); // NOI18N

        jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
        jCheckBox1.setName("jCheckBox1"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jCheckBox1)
                .addContainerGap(235, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .add(jCheckBox1)
                .add(58, 58, 58))
        );

        deathYearField.setName("deathYearField"); // NOI18N

        commemorationMonthCombo.setMaximumRowCount(12);
        commemorationMonthCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "---", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }));
        commemorationMonthCombo.setName("commemorationMonthCombo"); // NOI18N

        nameLabel1.setText(resourceMap.getString("nameLabel1.text")); // NOI18N
        nameLabel1.setName("nameLabel1"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        birthLocationLabel.setText(resourceMap.getString("birthLocationLabel.text")); // NOI18N
        birthLocationLabel.setName("birthLocationLabel"); // NOI18N

        birthLocationField.setName("birthLocationField"); // NOI18N

        lifeLocationLabel.setText(resourceMap.getString("lifeLocationLabel.text")); // NOI18N
        lifeLocationLabel.setName("lifeLocationLabel"); // NOI18N

        lifeLocationField.setName("lifeLocationField"); // NOI18N

        deathLocationLabel.setText(resourceMap.getString("deathLocationLabel.text")); // NOI18N
        deathLocationLabel.setName("deathLocationLabel"); // NOI18N

        deathLocationField.setName("deathLocationField"); // NOI18N

        relicsLocationLabel.setText(resourceMap.getString("relicsLocationLabel.text")); // NOI18N
        relicsLocationLabel.setName("relicsLocationLabel"); // NOI18N

        relicsLocationField.setName("relicsLocationField"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel1Layout.createSequentialGroup()
                            .add(8, 8, 8)
                            .add(birthLocationLabel))
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(lifeLocationLabel)
                            .add(deathLocationLabel)))
                    .add(relicsLocationLabel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(relicsLocationField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                    .add(deathLocationField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, lifeLocationField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                    .add(birthLocationField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(birthLocationField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(birthLocationLabel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lifeLocationField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(lifeLocationLabel))
                .add(8, 8, 8)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(deathLocationField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(deathLocationLabel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(relicsLocationField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(relicsLocationLabel)))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        lifeStoryField.setColumns(20);
        lifeStoryField.setLineWrap(true);
        lifeStoryField.setRows(5);
        lifeStoryField.setWrapStyleWord(true);
        lifeStoryField.setName("lifeStoryField"); // NOI18N
        jScrollPane3.setViewportView(lifeStoryField);

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 724, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
        );

        commemorationDayCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        commemorationDayCombo.setName("commemorationDayCombo"); // NOI18N

        jPanel4.setBackground(resourceMap.getColor("jPanel4.background")); // NOI18N
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel4.border.title"))); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        importIconTextField.setText(resourceMap.getString("importIconTextField.text")); // NOI18N
        importIconTextField.setName("importIconTextField"); // NOI18N

        importIconButton.setAction(actionMap.get("importImageButtonPressed")); // NOI18N
        importIconButton.setText(resourceMap.getString("importIconButton.text")); // NOI18N
        importIconButton.setName("importIconButton"); // NOI18N

        navigateButton.setAction(actionMap.get("openFileChoser")); // NOI18N
        navigateButton.setText(resourceMap.getString("navigateButton.text")); // NOI18N
        navigateButton.setIconTextGap(2);
        navigateButton.setName("navigateButton"); // NOI18N

        deleteImageButton.setText(resourceMap.getString("deleteImageButton.text")); // NOI18N
        deleteImageButton.setName("deleteImageButton"); // NOI18N

        iconsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        iconsComboBox.setName("iconsComboBox"); // NOI18N
        iconsComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                iconsComboBoxActionPerformed(evt);
            }
        });

        iconsImagePanel.setName("iconsImagePanel"); // NOI18N

        org.jdesktop.layout.GroupLayout iconsImagePanelLayout = new org.jdesktop.layout.GroupLayout(iconsImagePanel);
        iconsImagePanel.setLayout(iconsImagePanelLayout);
        iconsImagePanelLayout.setHorizontalGroup(
            iconsImagePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 362, Short.MAX_VALUE)
        );
        iconsImagePanelLayout.setVerticalGroup(
            iconsImagePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 312, Short.MAX_VALUE)
        );

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(importIconTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                        .add(1, 1, 1)
                        .add(navigateButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(iconsComboBox, 0, 281, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(importIconButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(deleteImageButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 75, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
            .add(iconsImagePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
                .add(iconsImagePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(deleteImageButton)
                    .add(iconsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(importIconTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(importIconButton)
                    .add(navigateButton)))
        );

        birthYearLabel.setText(resourceMap.getString("birthYearLabel.text")); // NOI18N
        birthYearLabel.setName("birthYearLabel"); // NOI18N

        nameLabel.setText(resourceMap.getString("nameLabel.text")); // NOI18N
        nameLabel.setName("nameLabel"); // NOI18N

        birthYearLabel1.setText(resourceMap.getString("birthYearLabel1.text")); // NOI18N
        birthYearLabel1.setName("birthYearLabel1"); // NOI18N

        birthYearField.setName("birthYearField"); // NOI18N

        birthYearLabel2.setText(resourceMap.getString("birthYearLabel2.text")); // NOI18N
        birthYearLabel2.setName("birthYearLabel2"); // NOI18N

        nameField.setName("nameField"); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList1.setMaximumSize(null);
        jList1.setMinimumSize(null);
        jList1.setName("jList1"); // NOI18N
        jList1.setPreferredSize(null);
        jList1.setVisibleRowCount(1);
        jScrollPane1.setViewportView(jList1);

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jButton1.setName("jButton1"); // NOI18N

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jButton2.setName("jButton2"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jList2.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList2.setMaximumSize(null);
        jList2.setMinimumSize(null);
        jList2.setName("jList2"); // NOI18N
        jList2.setPreferredSize(null);
        jList2.setVisibleRowCount(1);
        jScrollPane2.setViewportView(jList2);

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jButton1)
                    .add(jButton2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 155, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jButton1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton2)
                .addContainerGap())
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
        );

        okayButtonPersonEditor.setAction(actionMap.get("okayButtonPressed")); // NOI18N
        okayButtonPersonEditor.setText(resourceMap.getString("okayButtonPersonEditor.text")); // NOI18N
        okayButtonPersonEditor.setName("okayButtonPersonEditor"); // NOI18N

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(268, 268, 268)
                .add(cancelButtonPersonEditor)
                .add(88, 88, 88)
                .add(okayButtonPersonEditor)
                .addContainerGap(238, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jPanel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                .add(nameLabel)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
                                .add(18, 18, 18)
                                .add(birthYearLabel)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(birthYearField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(4, 4, 4)
                                .add(birthYearLabel1)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(deathYearField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(birthYearLabel2)))
                        .add(5, 5, 5)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(113, 113, 113)
                                .add(nameLabel1)
                                .add(2, 2, 2)
                                .add(commemorationMonthCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(commemorationDayCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(layout.createSequentialGroup()
                                .add(1, 1, 1)
                                .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(nameLabel)
                    .add(commemorationMonthCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(commemorationDayCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(nameLabel1)
                    .add(birthYearLabel)
                    .add(birthYearField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(birthYearLabel1)
                    .add(deathYearField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(birthYearLabel2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 109, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(5, 5, 5)
                .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(cancelButtonPersonEditor)
                    .add(okayButtonPersonEditor)))
        );

        okayButtonPersonEditor.getAccessibleContext().setAccessibleName(resourceMap.getString("okayPersonEdit.AccessibleContext.accessibleName")); // NOI18N

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void iconsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_iconsComboBoxActionPerformed
        updateIcon();
}//GEN-LAST:event_iconsComboBoxActionPerformed



    /**
    * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                PersonEditorDialog dialog = new PersonEditorDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField birthLocationField;
    private javax.swing.JLabel birthLocationLabel;
    private javax.swing.JTextField birthYearField;
    private javax.swing.JLabel birthYearLabel;
    private javax.swing.JLabel birthYearLabel1;
    private javax.swing.JLabel birthYearLabel2;
    private javax.swing.JButton cancelButtonPersonEditor;
    private javax.swing.JComboBox commemorationDayCombo;
    private javax.swing.JComboBox commemorationMonthCombo;
    private javax.swing.JTextField deathLocationField;
    private javax.swing.JLabel deathLocationLabel;
    private javax.swing.JTextField deathYearField;
    private javax.swing.JButton deleteImageButton;
    private javax.swing.JComboBox iconsComboBox;
    private vita.ImagePanel iconsImagePanel;
    private javax.swing.JButton importIconButton;
    private javax.swing.JTextField importIconTextField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextField lifeLocationField;
    private javax.swing.JLabel lifeLocationLabel;
    private javax.swing.JTextArea lifeStoryField;
    private javax.swing.JTextField nameField;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JLabel nameLabel1;
    private javax.swing.JButton navigateButton;
    private javax.swing.JButton okayButtonPersonEditor;
    private javax.swing.JTextField relicsLocationField;
    private javax.swing.JLabel relicsLocationLabel;
    // End of variables declaration//GEN-END:variables

}
